Feedback-directed optimization (FDO) is a technique used to tune application executions based on application runtime behavior in order to improve performance. FDO is also known as Profile Guided Optimization (PGO) and Profile Based Optimization (PBO). In order to tune applications, FDO conducts profiling on the applications. Profiling is the process of gathering information about how an application behaves during runtime. This profile information is used to drive decisions regarding various application optimizations.
As illustrated in FIG. 1, customary feedback-directed optimization is a dual build model technique that uses static instrumentation to collect edge and value profiles. An instrumentation build (101) allows the compiler to insert code into an application's binary to create an instrumented version of the binary (102). This inserted code typically counts edges or collects value profiles. The instrumented binary (102) is run on a representative set of training data (104) in a training run (103). At the end of the training execution, all collected edge counts and value information is written and aggregated in a profile database or gcov data file (GCDA) (105). An optimization build (106) then occurs in which the compiler uses the generated profile to make optimization decisions such as inline decisions, instruction scheduling, basic block re-ordering, function splitting, and register allocation.
Some applications contain multiple function calls and nested function calls. These function calls may be profiled in order to understand how many times they are executed. Each call to function may result in several instructions being executed, including the function call itself and the function return, which may be costly. Function calls are also barriers blocking other compiler optimizations such as constant propagation, redundancy elimination, dead code elimination among other optimizations. In order to improve an application's performance, function calls should be optimized. One way to minimize function calls is to inline the function behavior into the callsite where the behavior is called.
When performing FDO, two issues to consider are: (1) how to represent the generated profile and map the profile back to the compiler and (2) how the compiler will use the generated profile. These two issues can affect the generated profile's performance. The profile should accurately reflect the application's actual runtime behavior. There should be an approach for creating profiles that accurately and completely represent an application's runtime behavior and improve the performance of the binaries.